import urllib.request


url = 'https://www.mcdonalds.com.cn/index/Food/menu/burger'

response = urllib.request.urlopen(url=url)

content = response.read().decode('utf-8')

# print(content)

from bs4 import BeautifulSoup

soup = BeautifulSoup(content, 'lxml')

# img = //div[@class="pic"]/img/@src
# name = //span[@class="name"]
name_list = soup.select('.name')
# 可以写成
names = soup.select('span[class="name"]')
images = soup.select('.pic img')

for i in range(len(names)):
    # print(names[i].string)
    print(names[i].get_text(), images[i].attrs.get('src'))


# obj = soup.select('.pic img')
# for i in obj:
#     print(i.attrs.get('src'))

